package com.godpaper.the5elements.model
{
	import com.godpaper.the5elements.busniess.managers.PlayerManager;
	import com.godpaper.the5elements.views.components.PieceButton;
	
	import mx.collections.ArrayCollection;

	public class PiecesModel
	{
		// Singleton instance of PiecesModel
		private static var instance:PiecesModel;
		public function PiecesModel(access:Private)
		{
			if (access != null)
			{
				if (instance == null)
				{				
					instance = this;
				}
			}
			else{
				throw new Error( "PiecesModel.SINGLETON_EXCEPTION", "@PiecesModel" );
			}
		}
		
		/**
		 * 
		 * @return the Singleton instance of PiecesModel
		 * 
		 */		
		public static function getInstance():PiecesModel
		{
			if(instance == null)
			{
				instance = new PiecesModel(new Private());
			}
			return instance;
		}
//--------------------------------------------------------------------------
//
//  Variables
//
//--------------------------------------------------------------------------	
		[Bindable]public var selectedPiece:PieceButton;
//--------------------------------------------------------------------------
//
//  Properties
//
//--------------------------------------------------------------------------
		//--------------------------------------------------------------------------
		//
		//  redPiecesCollection
		//
		//--------------------------------------------------------------------------			
		private var _redPiecesCollection:ArrayCollection=new ArrayCollection();
		public function set redPiecesCollection(value:ArrayCollection):void
		{
			_redPiecesCollection = value;
			if(value.length==0)
			{
				PlayerManager.humanWin();
			}
		}
		[Bindable]
		public function get redPiecesCollection():ArrayCollection
		{
			return _redPiecesCollection;
		} 
		//--------------------------------------------------------------------------
		//
		//  bluePiecesCollection
		//
		//--------------------------------------------------------------------------
		private var _bluePiecesCollection:ArrayCollection=new ArrayCollection();
		public function set bluePiecesCollection(value:ArrayCollection):void
		{
			_bluePiecesCollection = value;
			if(value.length==0)
			{
				PlayerManager.computerWin();
			}
		}
		[Bindable]
		public function get bluePiecesCollection():ArrayCollection
		{
			return _bluePiecesCollection;
		} 
		//--------------------------------------------------------------------------
		//
		//  gasketCollection
		//
		//--------------------------------------------------------------------------
		private var _gasketCollection:ArrayCollection = new ArrayCollection();
 		public function set gasketCollection(value:ArrayCollection):void
 		{
 			_gasketCollection = value;
 		}
 		[Bindable]
 		public function get gasketCollection():ArrayCollection
 		{
 			return _gasketCollection;
 		}
	}
}
/**
 * Inner class which restricts contructor access to Private
 */
class Private 
{
	
}